package com.lby.psychology.service;


import com.lby.psychology.mapper.PsycRoleMapper;
import com.lby.psychology.model.pojo.PsycRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestService {

    @Autowired
    private PsycRoleMapper roleMapper;

    @Transactional
    public void testTransactional() {
        errorFunction();
        throw new RuntimeException("主动异常");
    }

    private void errorFunction() {
        PsycRole role = new PsycRole();
        role.setRoleCode("myk");
        role.setRemark("测试事务");
        roleMapper.insertSelective(role);

    }

}
